/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-09-06
 * Time: 20:11
 */
public class ThreadDemo1 {
    private static Object locker1 = new Object();
    private static int count = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 5000; i++) {
                synchronized (locker1) {
                    count++;
                }
            }
        });

        Thread t2 = new Thread(() -> {
           for(int i = 0; i < 5000; i++) {
               synchronized (locker1) {
                   count++;
               }
           }
        });

        t1.start();
        t2.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            t2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(count);
    }
}
